﻿using System;
using UnityEngine;

// Token: 0x020000A0 RID: 160
public class CameraRig_Orbit : MonoBehaviour
{
	// Token: 0x0600051B RID: 1307 RVA: 0x0001E24C File Offset: 0x0001C44C
	private void Start()
	{
		this.cam = base.gameObject.GetComponentInChildren<Camera>();
		this.euler = base.transform.rotation.eulerAngles;
		this.distance = this.cam.transform.localPosition.magnitude;
	}

	// Token: 0x0600051C RID: 1308 RVA: 0x0001E2A4 File Offset: 0x0001C4A4
	private void Update()
	{
		if (Input.GetMouseButton(1) && Input.GetMouseButton(2))
		{
			this.euler.z = 0f;
		}
		if (Input.GetMouseButton(0) && Input.GetMouseButton(2))
		{
			this.cam.fieldOfView = 45f;
		}
		if (Input.GetMouseButton(2) || (Input.GetMouseButton(0) && Input.GetMouseButton(1)))
		{
			Vector3 vector = default(Vector3);
			vector.x += Input.GetAxis("Mouse X") * this.moveSpeed;
			vector.z += Input.GetAxis("Mouse Y") * this.moveSpeed;
			vector = base.transform.rotation * vector;
			vector.y = 0f;
			base.transform.position += vector;
		}
		else if (Input.GetMouseButton(1))
		{
			float num = Input.GetAxis("Mouse X") * this.moveSpeed;
			this.distance = Mathf.Max(0f, this.distance + num);
			Vector3 b = default(Vector3);
			b.y += Input.GetAxis("Mouse Y") * this.moveSpeed;
			base.transform.position += b;
			this.euler.z = this.euler.z + Input.GetAxis("Mouse ScrollWheel") * this.rollSpeed * (float)((!this.invR) ? 1 : -1);
		}
		else if (Input.GetMouseButton(0))
		{
			this.euler.y = this.euler.y + Input.GetAxis("Mouse X") * this.rotateSpeed * (float)((!this.invX) ? 1 : -1);
			this.euler.x = this.euler.x - Input.GetAxis("Mouse Y") * this.rotateSpeed * (float)((!this.invY) ? 1 : -1);
		}
		else
		{
			this.cam.fieldOfView -= Input.GetAxis("Mouse ScrollWheel") * this.zoomSpeed * (float)((!this.invZ) ? 1 : -1);
			this.cam.fieldOfView = Mathf.Clamp(this.cam.fieldOfView, 10f, 90f);
		}
		base.transform.rotation = Quaternion.Euler(this.euler);
		this.cam.transform.localPosition = Vector3.back * this.distance;
	}

	// Token: 0x0400040C RID: 1036
	[SerializeField]
	private float rotateSpeed = 5f;

	// Token: 0x0400040D RID: 1037
	[SerializeField]
	private float moveSpeed = 0.1f;

	// Token: 0x0400040E RID: 1038
	[SerializeField]
	private float zoomSpeed = 50f;

	// Token: 0x0400040F RID: 1039
	[SerializeField]
	private float rollSpeed = 50f;

	// Token: 0x04000410 RID: 1040
	[SerializeField]
	private bool invX;

	// Token: 0x04000411 RID: 1041
	[SerializeField]
	private bool invY;

	// Token: 0x04000412 RID: 1042
	[SerializeField]
	private bool invZ;

	// Token: 0x04000413 RID: 1043
	[SerializeField]
	private bool invR;

	// Token: 0x04000414 RID: 1044
	private Vector3 euler;

	// Token: 0x04000415 RID: 1045
	private Camera cam;

	// Token: 0x04000416 RID: 1046
	private float distance = 1f;
}
